class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-04-08",
      revision: "50cc2edafef34ed65706b83678f765fbdc83eaf4"
  version "2022-04-08"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "4723f7c4eef7a359b1354404aeddbde2233b3c07e5436cc6b6e9c4196783f03f"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "bc82184b74c09183975ca0b05b5e726799109cd7e914574d04bd05921376e61b"
    sha256 cellar: :any_skip_relocation, monterey:       "ee4733d82d3a6f7a1664fe1849bfe78627c85d688c98a9ee429403ce8991d81b"
    sha256 cellar: :any_skip_relocation, big_sur:        "c11254dad3c1fad094087807fb55f8adb8b61c3f1cafdfdff34fb3daf7255d2f"
    sha256 cellar: :any_skip_relocation, catalina:       "0cbba257d30979df26efa30c45f7f8e179ee22d5731bc07793dbd894ffdaa735"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "0b0a3ad445d858d3420129e3d2a70b83cebad3efcc1572985df16c6b045c7c33"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
